<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.util.Date" %>  
<%@ page import="java.sql.*" %>  
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>


<% 
  
    // 接收用户数据
    request.setCharacterEncoding("utf-8");
 
    String dish_id = request.getParameter("dish_id");
    String name = request.getParameter("name");
    String price = request.getParameter("price");
    String amount = request.getParameter("amount");
    String table_id = request.getParameter("table_id");
    String restaurant_id = request.getParameter("restaurant_id");
    String status ="waiting";
    String pay = "未支付";
   
   
   
    String btn = request.getParameter("btn");
    String sql = "";
    //insert
    sql = "insert into shoppingcar(restaurant_id,dish_id,name,price,amount,table_id,status,pay) values('"+ restaurant_id +"','"+ dish_id +"','"+ name +"','"+ price +"','"+ amount +"','"+table_id +"','"+status +"','"+pay +"')";
    
    if("修改".equals(btn)){
    	 //update
        sql = "update shoppingcar set dish_id='" + dish_id +"',name='" + name +"',amount='" + amount +"',table_id='" + table_id +"' where dish_id='"+ dish_id +"'";
    }else if("del".equals(btn)){
    	
    	//delete
        sql = "delete from shoppingcar where dish_id='"+ dish_id + "'";
    }
    	
     
    int ret = aa.db.DBTools.update(sql);
    System.out.println("ret=" + ret);
    //返回到页面
    response.sendRedirect("shoppingcar.jsp");
    
    

  %>

</body>
</html>